% script that calls Newmark Integration for sample problem
% Written by Dr Colin Caprani - www.colincaprani.com

m = 10;
k = 100;
xi = 0.1;
u0 = 0;
ud0 = 0;
t = 0:0.1:4.0;              % set the time vector
F = zeros(1,length(t));     % empty F vector
% set sinusoidal force of 10 over 0.6 s
Famp = 10;
Tend = 0.6;
i = 1;
while t(i) < Tend
    F(i) = Famp*sin(pi*t(i)/Tend);
    i = i+1;
end

[u ud udd] = newmark_sdof(m, k, xi, t, F, u0, ud0, 1);

% script that finds explosion response
m = 10;
k = 100;
xi = 0.1;
u0 = 0;
ud0 = 0;
Fmax = 50;      % N
Tend = 0.2;     % s
t = 0:0.01:4.0;             % set the time vector
F = zeros(1,length(t));     % empty F vector
% set reducing triangular force
i = 1;
while t(i) < Tend
    F(i) = Fmax*(1-t(i)/Tend);
    i = i+1;
end

[u ud udd] = newmark_sdof(m, k, xi, t, F, u0, ud0, 1);